package org.xxpay.pay.channel.munion;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.xxpay.common.unify.AbstractPaymentConfig;

/**
 * @Package org.xxpay.pay.channel.munion
 * @Class: MunionpayConfig.java
 * @Description:
 * @Author leo
 * @Date 2019/4/9 10:11
 * @Version
 **/
@Component
@Data
@ToString
@NoArgsConstructor
public class MunionpayConfig extends AbstractPaymentConfig {

    public static final String CHANNEL_NAME = "munionpay";
    public static final String CHANNEL_NAME_WXQR = CHANNEL_NAME + "_wxqr";
    public static final String RETURN_VALUE_SUCCESS = "success";
    public static final String RETURN_VALUE_FAIL = "error"; // 失败返回码
    public static final String RESPONSE_RESULT_SUCCESS = "success"; // 返回上游成功
    public static final String RESPONSE_RESULT_FAIL = "fail";       // 返回上游失败

    // 请求地址查询串
    // 创建订单url查询串
    public static final String REQUEST_CREATE_ORDER = "/api/v1/orders";
    // 查询订单url查询串
    public static final String REQUEST_ORDER_QUERY = "/api/v2/payQuery";


    // 订单支付状态：1-支付成功 2-支付失败 其他状态按处理中..
    public static final String ASYNC_NOTIFY_STATUS_OK = "1";

    public MunionpayConfig(String payParam) {
        Assert.notNull(payParam, "init munion pay config error");
        JSONObject object = JSON.parseObject(payParam);
        setMchId(object.getString("mchId"));
        setPrivateKey(object.getString("privateKey"));
        setRequestUrl(object.getString("requestUrl"));
        // 微信扫码：newpos
        setPayMode(object.getString("payMode"));
    }

}
